home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10413 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  57 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!jodell
  3. From: jodell@netcom.com (Jake Odell)
  4. Subject: Re: Help !!!!! on 'strstr"
  5. Message-ID: <jodellDoF8tu.EAL@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. References: <314703FF.4045@msmail.st.stems.com> <DoE30t.G5u@iquest.net>
  9. Date: Sun, 17 Mar 1996 17:05:54 GMT
  10. Sender: jodell@netcom8.netcom.com
  11.  
  12. Doug & Rose Miller (dlmiller@iquest.net) posted:
  13. # kim hai <Kim_Hai.Ng@msmail.st.stems.com> wrote:
  14. # +Help !!!!!
  15. # +
  16. # +Problem :
  17. # +    I need to locate a string within another string, and the process
  18. # +must be case insensitive. As far as I know, strstr() only locates the
  19. # +exact match and is case sensitive.
  20. # +    Does anyone konw of any functions that could allow me to locate
  21. # +substrings and is case insensitive ?
  22. # +
  23. # +Eg.
  24. # +case 1:
  25. # +    string1 = "abc"
  26. # +    string2 = "abcdef"
  27. # +case 2:
  28. # +    string2 = "Abcdef"
  29. # +case 3:
  30. # +    string3 = "aBcdef"
  31. # +case 4:
  32. # +    string4 = "abCdef"
  33. # +.....
  34. # +....
  35. # +...
  36. # +
  37. # +Is taking care of all the combinations ( = 8) in string1 the only
  38. # +solution ? I'm working on Unix platform.
  39. # +
  40. # +Thankx
  41. # +
  42. # +<hai>
  43. # +
  44. # Use strupr() on both strings -- to insure they are both the same case
  45. # -- before using strstr().  Of course, strlwr() would work also.
  46.  
  47. # Perhaps you should copy both strings to temporary areas and use
  48. # strupr() on the temps, because it does not merely return the
  49. # case-shifted string, it actually case-shifts the original.
  50.  
  51.  
  52. Several others suggested this or similar approaches; I don't think this
  53. is a good technique for a general purpose solution, as you shouldn't
  54. modify the input strings, nor should there be length limits on them.
  55. -- 
  56. jake@pantheon.us.com   jodell@netcom.com
  57.